home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / siv / scroll1.inc < prev    next >
Text File  |  1994-04-25  |  6KB  |  268 lines

  1. ;       The SenSiv Scrolling Routines
  2. ────────────────────────────────────────────────────────────────────────────────
  3. ; Copyright 1994 by SiV productions, All rights reserved.
  4. ; Copyright 1994 by Tali Streit, All rights reserved.
  5. ────────────────────────────────────────────────────────────────────────────────
  6.  
  7. ;       Module1
  8.  
  9.  
  10.  
  11. ;  ▄▀▀▀▀▀▀▀▄
  12. ; █  │   │  █
  13. ; █  └─┬─┘  █
  14. ; █    │    █
  15. ; █    │    █
  16. ;  ▀▄▄▄▄▄▄▄▀
  17.  
  18. update_scroll1:
  19. updatescroll1:
  20. rendy:
  21.         mov     bx, moveY
  22.         or      bx, bx
  23.         js      donegY
  24.  
  25.         and     bx, 15          ; do not handle scrolls larger then 16..
  26.         shl     bx, 1
  27.         mov     ax, rows[bx]
  28.         shr     bx, 1
  29.         add     SCRorigin, ax
  30.         jmp     doposY
  31.  
  32. donegY: neg     bx
  33.         and     bx, 15          ; do not handle scrolls larger then 16...
  34.         shl     bx, 1
  35.         mov     ax, rows[bx]
  36.         sub     SCRorigin, ax
  37.         shr     bx, 1
  38.         neg     bx
  39.  
  40. doposY:
  41. ;        shr     bx, 1
  42. ;        mov     bx, moveY
  43.         add     Ypos, bx
  44.         add     indexY, bx      ; The 16 counter index thing.
  45.         js      goUP
  46.         cmp     indexY, 16
  47.         jb      noYch
  48. ;
  49. ;│   │ ┌── ┌  ┌
  50. ;└─┬─┘ │   ├──┤  ─┼─
  51. ;  │   └── ┘  ┘
  52. ;
  53.     mov    di, mapX    ;┌ update the map pointer.
  54.         add     source, di      ;│
  55.  
  56.         mov     di, SCRorigin    ;┌ calculate 128 pixels down from origin
  57.         add     di, 128*320      ;│
  58.  
  59.         sub     indexY, 16      ;┌ Subtract the error term...
  60.         mov     bx, indexY      ;│
  61.         shl     bx,1            ;│
  62.         sub     di, rows[bx]    ;│
  63.         sub     di, indexX      ;│
  64.  
  65.         mov     si, source
  66.     mov    ax, mapX
  67.  
  68.     add    si, ax        ;┌ point to the right line in the map
  69.     add    si, ax        ;│
  70.     add    si, ax        ;│
  71.     add    si, ax        ;│
  72.     add    si, ax        ;│
  73.     add    si, ax        ;│
  74.     add    si, ax        ;│
  75.     add    si, ax        ;│
  76.  
  77.     cmp    moveX,0
  78.         jns     nodoY
  79. ;        sub     di,16
  80. ;        dec     si
  81. nodoY:
  82.         ; DI points to destination place...
  83.         ; SI pointe to source place...
  84.     add    si,mapoff
  85.         mov     cx,background
  86.         call    do_row
  87.     jmp    noYch
  88.  
  89. ;
  90. ;│   │ ┌── ┌  ┌
  91. ;└─┬─┘ │   ├──┤  ───
  92. ;  │   └── ┘  ┘
  93. ;
  94.  
  95. goUP:   ; indexY should be negative...
  96.     mov    di,mapX
  97.     sub    source,di
  98.  
  99.     mov    di,SCRorigin
  100.     sub    di,16*320
  101.  
  102.     mov    bx, indexY    ;┌ subtract error term.....
  103.     neg    bx        ;│
  104.     shl    bx, 1        ;│
  105.     add    di, rows[bx]    ;│
  106.         sub     di, indexX      ;│
  107.  
  108.     add    indexY, 16    ;┌ make indexY usable again....
  109.  
  110.     mov    si, source    ;┌ make si point to top line.
  111. ;        sub     si, mapX        ;│
  112.  
  113.     cmp    moveX, 0
  114.     jns    nodoY2
  115.         ;sub     di, 16
  116.         ;dec     si
  117. nodoY2:
  118.     ; DI points to destination place...
  119.         ; SI pointe to source place...
  120.     add    si, mapoff
  121.         mov     cx,background
  122.         call    do_row
  123.  
  124. noYch:
  125.  
  126. ;  ▄▀▀▀▀▀▀▀▄
  127. ; █  │   │  █
  128. ; █  └─┬─┘  █
  129. ; █  ┌─┴─┐  █
  130. ; █  │   │  █
  131. ;  ▀▄▄▄▄▄▄▄▀
  132. ;
  133. rendX:
  134.     mov    bx, moveX
  135.         or      bx, bx
  136.     js    donegX
  137.  
  138.         and     bx, 15          ; do not handle scrolls larger then 16..
  139.     add    SCRorigin, bx
  140.     jmp    doposX
  141.  
  142. donegX: neg     bx
  143.         and     bx, 15          ; do not handle scrolls larger then 16...
  144.         neg     bx
  145.         add     SCRorigin, bx
  146.  
  147. doposX: add     Xpos, bx
  148.     add    indexX, bx    ; The 16 counter index thing.
  149.     js    goback
  150.     cmp    indexX, 16
  151.     jb    noXch
  152. ;
  153. ;└┐ ┌┘ ┌── ┌  ┌
  154. ; ├─┤  │   ├──┤  ─┼─
  155. ;┌┘ └┐ └── ┘  ┘
  156. ;
  157.     inc    source        ; Update the source pointer (map)
  158.  
  159.     mov    di, SCRorigin     ;┌ calculate 128 pixels right from origin
  160.     add    di, 128      ;│
  161.  
  162.     sub    indexX, 16    ;┌ Subtract the error term...
  163.     sub    di, indexX    ;│
  164.         mov     bx, indexY      ;│
  165.         shl     bx,1            ;│
  166.         sub     di, rows[bx]    ;│
  167.  
  168.         mov     si, source
  169.     add    si, 8
  170.  
  171.         ; DI points to destination place...
  172.         ; SI pointe to source place...
  173.     add    si,mapoff
  174.         mov     cx,background
  175.         call    do_col
  176.     jmp    noXch
  177.  
  178. ;
  179. ;│   │ ┌── ┌  ┌
  180. ;└─┬─┘ │   ├──┤  ───
  181. ;┌─┴─┐ └── ┘  ┘
  182. ;│   │
  183.  
  184. goback:   ; indexX should be negative...
  185.     dec    source
  186.  
  187.     mov    di,SCRorigin
  188.     sub    di,16
  189.  
  190.     mov    bx, indexX    ;┌ subtract error term.....
  191.     neg    bx        ;│
  192.     add    di, bx        ;│
  193.         mov     bx, indexY      ;│
  194.         shl     bx,1            ;│
  195.         sub     di, rows[bx]    ;│
  196.  
  197.     add    indexX, 16    ;┌ make indexX usable again....
  198.  
  199.     mov    si, source    ;┌ make si point to left col
  200. ;        dec     si              ;│
  201.  
  202.     ; DI points to destination place...
  203.         ; SI pointe to source place...
  204.     add    si, mapoff
  205.         mov     cx,background
  206.         call    do_col
  207.  
  208. noXch:
  209.         ret
  210.  
  211. Check1:
  212.         mov     bx,Xpos
  213.         add     bx,MoveX
  214.         cmp     bx,maxXpos
  215.         jl      noXwrap
  216.         neg     MoveX
  217. noXwrap:
  218.         cmp     bx,minXpos
  219.         jg      noXwarp2
  220.         neg     MoveX
  221. noXwarp2:
  222.         mov     bx,Ypos
  223.         add     bx,MoveY
  224.         sub     bx,16
  225.         cmp     bx,maxYpos
  226.         jl      noYwarp
  227.         neg     MoveY
  228. noYwarp:
  229.         cmp     bx,minYpos
  230.         jg      noYwarp2
  231.         neg     MoveY
  232. noYwarp2:
  233.         ret
  234.  
  235. initscroll1:     ; this takes Xpos and Ypos and calculates the rest.
  236.         mov     cx,mapx
  237.         sub     cx,8
  238.         shl     cx,4
  239.         mov     maxxpos,cx
  240.  
  241.         mov     ax,mapy
  242.         sub     ax,8
  243.         shl     ax,4
  244.         mov     maxYpos,ax
  245.  
  246.         mov     bx,Ypos
  247.         shl     bx,1
  248.         mov     di,rows[bx]
  249.         add     di,Xpos
  250.         mov     SCRorigin,di
  251.         mov     bx,Xpos
  252.         and     bx,15
  253.         mov     indexX,bx
  254.         mov     bx,Ypos
  255.         and     bx,15
  256.         mov     indexY,bx
  257.  
  258.         mov     bx, Ypos
  259.         shr     bx, 4
  260.         mov     ax, mapX
  261.         mul     bx
  262.         mov     source, ax
  263.         mov     bx, Xpos
  264.         shr     bx, 4
  265.         add     source, bx
  266.         ret
  267.  
  268.